<?php
namespace app\index\model;
use think\Model;

class Openplate extends model{
	function findstatus($tatatime){
		$res = $this->where('datetime',$tatatime)->find();
		return $res['status'];
	}
	function tfindopent(){
		$res=db('openplate')->where('opentime','<',time())->where('tclosetime','>',time())->find();
		return $res['tclosetime'];
	}
	function finddata(){
		$res=db('openplate')->where('opentime','<',time())->where('tclosetime','>',time())->find();
		return $res['datetime'];
	}
	function zfindopent(){
		$res=db('openplate')->where('opentime','<',time())->where('zclosetime','>',time())->find();
		return $res['zclosetime'];
	}
	function findtype($tatatime){
		$res = $this->where('datetime',$tatatime)->find();
		return $res['type'];
	}
	function finddatename(){
		$res = db('openplate')->where('opentime','<',time())->where('tclosetime','>',time())->find();
		if(!$res){
			$res = $this->order('datetime desc')->find();
			return $res['datetime'];
		}
		return $res['datetime'];
	}
	function findall(){
		$res = db('openplate')->select();
		return $res;
	}
	function openztype(){
		// 正码码开封盘
		$res = db('openplate')->where('opentime','<',time())->where('zclosetime','>',time())->find();
		if(!$res){
			return 0;
		}
		return $res['status'];
	}
	function openttype(){
		// 特码开封盘
		$res = db('openplate')->where('opentime','<',time())->where('tclosetime','>',time())->find();
		if(!$res){
			return 0;
		}
		return $res['type'];
	}

	function findqishu(){
		$res = db('openplate')->where('id',7)->find();
		return $res;
	}
}